@extends('layouts.app')
@section('content')
    <div class="container">
        <div class="row">
            <div class="col-sm-8">
                <div class="card">
                    <div class="card-header">
                        {{ $content -> title }}
                    </div>
                    <div class="card-body">
                        {!! $content -> content !!}
                    </div>
                </div>@include('layouts._message')

                <div class="row mt-3">

                    <div class="col-sm-12">
                        <div class="card">
                            <div class="card-header">
                                评论列表
                            </div>
                            <div class="card-body">
                                @foreach($content->comment as $comment)
                                    <ul class="list-group">
                                        <li class="list-group text-muted">
                                            <div class="row">
                                                <div class="col-sm-8">
                                                    {{$comment -> content}}
                                                </div>
                                                <div class="col-sm-4 text-right">
                                                    <small class="secondary text-left">{{$comment->user->name}}</small>
                                                    <small
                                                        class="secondary">{{$comment -> updated_at->diffForHumans()}}</small>
                                                </div>
                                            </div>
                                        </li>
                                    </ul>
                                @endforeach
                            </div>
                            <div class="card-footer text-muted">
                                @guest
                                    <div class="container">
                                        <div class="text-center"><a href="/login">请登录后发表评论</a></div>
                                    </div>
                                @else
                                    <form action="/article/comment" method='post'>
                                        @method('POST')
                                        <input type="hidden" value="{{$content -> id}}" name="content_id">
                                        @csrf
                                        <div class="form-group">
                                            <textarea class="form-control" name="content" id="" rows="3"
                                                      placeholder="请输入评论内容"></textarea>
                                        </div>
                                        <div class="form-group">
                                            <button type="submit" class="btn btn-secondary">
                                                发表评论
                                            </button>
                                        </div>
                                    </form>
                                @endguest
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-3">
                <div class="card">
                    <div class="card-header">
                        热门文章
                    </div>
                    <div class="card-block">
                        @list(['ishot'=>1,'limit' => 10])
                        <ul class="list-group">
                            <a class="list-group" href="{{$field['url']}}"> {{$field['title']}}</a>
                        </ul>
                        @endList
                    </div>
                </div>
            </div>
        </div>
@endsection

